<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/connopen.asp"-->
<!--#include file="lib/asp-common-lib.asp"-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>报关单登记系统</title>
<!--#include file="lib/plugins.asp"-->
<style type="text/css">
  .ui-datepicker table {
    border: 0;
  }
  .ui-autocomplete-loading { 
    background: white url('images/ui-anim_basic_16x16.gif') left center no-repeat; 
  }
  .ui-autocomplete,.ui-menu-item .ui-corner-all {
      border-radius: 0;
  }
  thead th{
    text-align:center;
    background:#e0e0e0;
  }
  tbody th[scope="row"],tbody th.sub{
    text-align:center;
  }
  input,select{
    border:1px solid #888888;
  }
  input:hover,input:active,select:hover,select:active{
    border:1px solid #aa6666
  }
  input[type=text]{
    padding:2px;
    margin:1px 0;
  }
  #pagebar{
    float:right;
  }
  #search_bar{
    border-width:1px 0;
  }
  #search_bar td{
    padding:1px;
    border-width:0;
  }
  #search_bar tr:hover td{
    background:#fff;
  }
  .bt_button{
    cursor: pointer;
    overflow: visible;
    width: auto;
    background: url("lib/yaml/screen/images/button_gray.png") repeat-x scroll left top #454545;
    border-color: #DDDDDD #444444 #444444 #DDDDDD;
    border-style: solid;
    border-width: 1px;
    color: #000000;
    padding: 5px 1em;
  }
  .bt_button:hover,.bt_button:active,.bt_button:focus{
    background: none repeat-x scroll left top #555555;
    border-color: #444444 #DDDDDD #DDDDDD #444444;
    color: #ffffff;
  }
  #page_go,#print_search,.bt_act{
    padding:0;
  }
  .chk{
    background-color:#d0d0d0;
  }
  #diaglog_print{
    display:none;
  }
  #lb_search{
    width:5.1em;
  }
  #bts_search{
    width:11.9em;
    text-align:right;
  }
  #adv_search{
    display:none;
  }
  #adv_search select{
    margin:1px 0;
  }
/* Tag cloud */
  
    #tags {  
      text-align:center; 
      padding:10px 0;  
      margin:5px 0;
      overflow:auto; 
    }  
    #tags ul { margin:0; padding:0; }  
    #tags ul li {  
      list-style-type:none; float:left; margin:-1px 10px; 
    }  
    #tags ul li a { text-decoration:none;  line-height:1.1em;}  
    #tags ul li a:hover { text-decoration:none; border:1px solid #aa6666}  
/* // Tag cloud */

/* select class */

    .sel{
      color:red;
    }
    .unsel{
      color:black;
    }
  
/* // select class */

</style>

<script type="text/javascript">
  $(function() {
    $.ajaxSetup ({
      cache: false, //关闭AJAX相应的缓存
      beforeSend:function() {
        $("#search_bar .ui-widget").addClass( "ui-autocomplete-loading" );
        $("#bt_search").attr("disabled",true);
      },
      complete:function() {
        $("#search_bar .ui-widget").removeClass( "ui-autocomplete-loading" );
        $("#bt_search").attr("disabled",false);
      }
    });
    $(".datepicker").datepicker();

    var p=1;
    function vi(p){
      $.get("todo_main.asp?page="+p+"&"+$("#fm_search").serialize(),function(data){//用ajax的get方式提交
        $("#search_main").html(data);

        $("#pagebar a").click(function(e){//对分页栏中的a元素进行操作
          e.preventDefault();//阻止a的原先事件
          vi($(this).attr("id"));//根据获取的页码值调用显示页面函数
        });
        $("#page_go").click(function(e){//对分页栏中的input元素进行操作
          e.preventDefault();
          if (isNaN($("#page_val").val())||$.trim($("#page_val").val())==""){//判断输入的是否是数字
            alert("输入的页码错误，请输入正确页码！");
            $("#page_val").select();
            return false;//页码值不是数字则退出；
          }
          vi($("#page_val").val());
        });
        
        var chk=$(".checkid");
        $("#checkall").click(function(){
          chk.prop("checked",$(this).prop("checked"));//根据全选的checkbox状态来填充单个checkbox状态
          $(this).prop("checked") ? chk.closest("tr").addClass("chk") : chk.closest("tr").removeClass("chk")//判断是否全部选中，选中则增加chk样式，没选中则删除chk样式，不能用toggleClass方法，由于下面单个checkbox会改变全选的checkbox状态
        });
        chk.click(function(){
          if(!$(this).prop("checked")) $("#checkall").prop("checked",false);//如果当前checkbox状态为未选中则全选的checkbox也设置为未选中
          $(this).closest("tr").toggleClass("chk");//单个切换当前checkbox存在的tr的chk样式
        });
        
        $(".bt_act").click(function(){
          $chks=$("#search_main input:checkbox.checkid:checked");
          if(confirm("要对这 "+$chks.length+" 条记录做"+$(this).val()+"操作吗？")){
            var aChk=new Array();
            $chks.each(function(){
              aChk.push($(this).val());
            });
            $.post("batch.asp",{chks:aChk.join(),act:$(this).val()},function(data){
              if(data.bStatus){
                vi($("#page_val").val());
              }else{
                alert(data.sInfo);
              }
            },"json");
          }
        });
        
      });

    }
    
    $("#bt_search").click(function(){
      var start_time = new Date().getTime();
      vi(p);
      var end_time = new Date().getTime();
      $("#show_runtime").html(end_time-start_time);
    });
    $("#show_adv").click(function(){
      $("#adv_search").toggle();
    });
    
    $("#search_bar input[type=reset]").click(function(){
      $("#search_bar select").removeClass("sel")
        .children().removeClass("unsel");
    });
    
    $("#search_bar select").change(function(){
      //console.log($(this).find("option:selected").index());
      $sel=$(this).find("option:selected");
      if($sel.index()>0){
        $sel.removeClass("unsel")
          .siblings().addClass("unsel")
          .parent().addClass("sel");
      }else{
        $sel.parent().removeClass("sel")
          .children().removeClass("unsel");
      }
    });



    $("#calendar").datepicker({
        showButtonPanel: true,
        onSelect:function(dateText,inst){
            //console.log(dateText);
            get_todos(dateText,"");
        }
    });

    $(".ui-datepicker-current").live('click',function(){
        //console.log($("#calendar").datepicker("getDate"));
        var today=new Date();
        get_todos(today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate(),"");
    });
    
    function render_todos(todos){
        var $ol=$("<ol></ol>");
        $.each(todos,function(i,item){
            //console.log(item);
            var $edit=$('<a href="#" title="编辑" class="todo_edit todo_hide"><span class="ui-icon ui-icon-pencil"></span></a>');
            var $done=$('<a href="#" title="完成" class="todo_done todo_hide"><span class="ui-icon ui-icon-check"></span></a>');
            var $dele=$('<a href="#" title="删除" class="todo_dele todo_hide"><span class="ui-icon ui-icon-close"></span></a>');
            var $redo=$('<a href="#" title="重启" class="todo_redo todo_hide"><span class="ui-icon ui-icon-arrowreturnthick-1-n"></span></a>');
            var $cdno=$('<a href="#" title="工单" class="todo_cdno todo_hide"><span class="ui-icon ui-icon-document"></span></a>');
            var $clock=$('<a href="#" title="提醒" class="todo_clock todo_hide"><span class="ui-icon ui-icon-clock"></span></a>');
            var $li=$("<li></li>");
            var $title=$("<span></span>").text(item["TITLE"]).addClass("todo_title");
            if(item["STAR"]){
                $title.addClass("star");
            }
            if(item["COMPLETE"]){
                $title.addClass("complete");
                $redo.removeClass("todo_hide");
            }else{
                $done.removeClass("todo_hide");
                $edit.removeClass("todo_hide");
                $dele.removeClass("todo_hide");
            }
            if(item["CD_NO"]){
                $cdno.removeClass('todo_hide');
            }
            if(item["ACTIVE_DATE"]){
                var $active=$("<code></code>").text(" <"+item["ACTIVE_DATE"]+">");
            }
            $li.data("foo",item["ID"])
                .data("cd",item["CD"])
                .attr('title',item["TODO"])
                .append($title)
                .append($active)
                .append($redo)
                .append($done)
                .append($dele)
                .append($edit)
                .append($cdno);
            
            
            
            $ol.append($li);
        });
        //console.log($ol);
        $("#dv_todos").empty().append($ol);
    }
    
    function get_todos(active,done){
        $.getJSON("json_todo.asp",{action:"查询",active_date:active,complete:done},function(data){
            if(data){
                render_todos(data);
            };
        },"json");
    }
    $(".ui-datepicker-current").trigger("click");
    //get_todos("",false);
    $("#view_allundonetodo").click(function(){
        get_todos("",false);
    });
    
    
    $("#tags ul li a").live("click",function(e){
      e.preventDefault();
      //alert($(this).html());
      $("#tx_search").val($(this).attr("href"));
      $("#bt_search").trigger("click");
    });
    
    // tag cloud

    $("#fm_search select").change(function(){
        vi(p);
    });
    
  });
</script>
<!--#include file="lib/js-google-analytics.asp"-->
</head>
<%
If Not CheckFlag(session("aaPostFlag"),1) Then Call JumpErrorPage(2)
%>
<body>
<!--#include file="lib/header.asp"-->
<!--#include file="lib/nav.asp"-->
<div id="main">

<!--#include file="lib/col1.asp"-->
<!--#include file="lib/col2.asp"-->
  <div id="col3" role="main">
    <div id="col3_content" class="clearfix">
      <form id="fm_search" name="fm_search">
        <table id="search_bar" class="full">
          <tr>
            <td id="lb_search"><label for="tx_search">查询内容：</label></td>
            <td>
              <div>
                <input id="tx_search" name="tx_search" type="text" />
                提醒日期
                <input name="ksrq" id="ksrq" class="datepicker" type="text" size="10" maxlength="10" readonly="readonly" />-<input name="jsrq" id="jsrq" class="datepicker" type="text" size="10" maxlength="10" readonly="readonly" />
                <select id="userid" name="userid">
                  <option value="0">选择员工</option>
                  
                  <%
                    Set rs_empe = Server.CreateObject("ADODB.Recordset")
                    sql = "SELECT * FROM username where employee=true order by fullname"
                    rs_empe.Open sql,conn,1,1
                    do while not rs_empe.eof
                  %>
                  <option value="<%=rs_empe("id")%>"><%=rs_empe("fullname")%>(<%=rs_empe("username")%>)</option>
                  <%
                      rs_empe.movenext
                    loop
                    rs_empe.close
                    set rs_empe=nothing
                  %>
                </select>
                <select id="search_star" name="search_star">
                  <option value="">任务级别</option>
                  <option value="true">重要</option>
                  <option value="false">普通</option>
                </select>
                <select id="search_complete" name="search_complete">
                  <option value="">是否完成</option>
                  <option value="true">完成</option>
                  <option value="false">未完成</option>
                </select>
                <select id="search_deleted" name="search_deleted">
                  <option value="">是否删除</option>
                  <option value="true">删除</option>
                  <option value="false">未删除</option>
                </select>
                <select id="search_cd" name="search_cd">
                  <option value="">是否关联报关单</option>
                  <option value="true">有关联</option>
                  <option value="false">无关联</option>
                </select>
                <select id="search_count" name="search_count">
                  <option value="100">最新100条</option>
                  <option value="0">全部</option>
                </select>
              </div>
            </td>
            <td id="bts_search">
              <div class="ui-widget">
              <input id="bt_search" class="bt_button" name="bt_submit" type="button" value="搜索" />
              <input class="bt_button" type="reset" value="重置" />
              </div>
            </td>
          </tr>
        </table>
      </form>
      <div id="search_main">
        <div class="subcolumns">
            <div class="c50l">
                <h2>
                    <b> = 我的任务列表 = </b> 
                    <button id="view_allundonetodo" type="button">待办任务</button>
                    <button class="create_newtodo" type="button" data-foo="todomain">新建任务</button>
                </h2>
                <div id="dv_todos"></div>
            </div>
            <div class="c50r">
                <div id="calendar"></div>
            </div>
      </div>
    </div>
  </div>
</div>
<!--#include file="lib/footer.asp"-->
</body>
</html>
<!--#include file="lib/connclose.asp"-->

